#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<windows.h>
#include<io.h>
#include<shellapi.h>
#include<set>
#include<map>
#include<ctime>
#include<fstream>
#include<vector>
#include<cstdlib>
#define INF 1999122700
#define LiangJiaJun main
using namespace std;
const int MAXN = 200000;
const int greps = 4;
///**************************************************************************
string read_operation,_now_name;
SYSTEMTIME _match_time={0};
#define _DATE _match_time.wYear <<"/"<<_match_time.wMonth<<"/"<<_match_time.wDay<<"-"<<_match_time.wHour<<":"<<_match_time.wMinute<<":"<<_match_time.wSecond<<"-"
string pre_text = "we have " ,
       _INSERT_text = "inserted" ,
       _DELETE_text = "deleted" ,
       _MODIFY_text = "modified"  ,
       last_text = "'s profile." ,
       _QUERY_text = "queried";
int key_number = 666666;
vector<string>_visual_name_in_set;
vector<int>AGE_serc;
int _COPY_IN_Set_(){
    _visual_name_in_set.clear();
    ///**********************************************************************
    freopen("SUM_people.log","r",stdin);
    int _now_sum;
    scanf("%d",&_now_sum);
    fclose(stdin);
    freopen("All_name_in_set_.txt","r",stdin);
    for(int i=1;i<=_now_sum;i++){
        string _w33ha_in_kappa;
        cin >> _w33ha_in_kappa;
        _visual_name_in_set.push_back(_w33ha_in_kappa);
    }
    ///**********************************************************************
    return 1;
}
int _UPDATE_TO_Set_(){
    freopen("All_name_in_set_.txt","w",stdout);
    for(int i=0;i<_visual_name_in_set.size();i++){
        cout<<_visual_name_in_set[i]<<endl;
    }
    fclose(stdout);
}
int _INSERT(){
    system("INSERT.bat");
    ///******************************************************************
    freopen("SUM_people.log","r",stdin);
    int _now_sum;
    scanf("%d",&_now_sum);
    ++_now_sum;
    fclose(stdin);
    freopen("SUM_people.log","w",stdout);
    printf("%d\n",_now_sum);
    fclose(stdout);
    ///******************************************************************
    freopen("the_name_we_used_now.txt","r",stdin);
    cin>>_now_name;
    fclose(stdin);
    ///*******************************************************************
    ofstream record_file;
    record_file.open("pre_record.log",ios::app);
    record_file<<"DATE:";

    record_file<<_DATE;

    record_file<<pre_text<<_INSERT_text<<" "<<_now_name<<last_text<<endl;
    record_file.close();
    ///********************************************************************
    ofstream name_file;
    name_file.open("All_name_in_set_.txt",ios::app);
    name_file<<_now_name<<endl;
    name_file.close();
    ///*********************************************************************
    return 1;
}
int _DELETE(){
    system("DELETE.bat");
    ///*************************************************************************
    freopen("the_name_we_used_now.txt","r",stdin);
    cin>>_now_name;
    fclose(stdin);
    ///***********************************************************************************************
    _COPY_IN_Set_();
    for(vector<string>::iterator it=_visual_name_in_set.begin();
        it!=_visual_name_in_set.end();it++){
        if((*it) == _now_name){_visual_name_in_set.erase(it);break;}
    }
    _UPDATE_TO_Set_();
    ///***********************************************************************************************
    freopen("SUM_people.log","r",stdin);
    int _now_sum;
    scanf("%d",&_now_sum);
    fclose(stdin);
    --_now_sum;
    freopen("SUM_people.log","w",stdout);
    printf("%d\n",_now_sum);
    fclose(stdout);
    ///*********************************************************************

    ///**********************************************************************
    ofstream record_file;
    record_file.open("pre_record.log",ios::app);
    record_file<<"DATE:";

    record_file<<_DATE;

    record_file<<pre_text<<_DELETE_text<<" "<<_now_name<<last_text<<endl;
    record_file.close();
    ///***********************************************************************

    return 1;
}
int _MODIFY(){
    system("MODIFY.bat");
    ///*********************************************************************
    freopen("the_name_we_used_now.txt","r",stdin);
    cin>>_now_name;
    fclose(stdin);
    ///************************************************************************
    ofstream record_file;
    record_file.open("pre_record.log",ios::app);
    record_file<<"DATE:";

    record_file<<_DATE;

    record_file<<pre_text<<_MODIFY_text<<" "<<_now_name<<last_text<<endl;
    record_file.close();
    ///***********************************************************************
    return 1;
}
int _DELETE_ALL(){
    int _now_number;
    string _uoic_input;

    puts("Please input the key code:");
    cin>>_now_number;
    if(_now_number != key_number) puts("The code is wrong");
    else {
        puts("Are you sure to delete all profile?(Y/N)");
        cin>>_uoic_input;
        if(_uoic_input == "Y"){
            system("delete_all.bat");
///*******************************************************************************
            ofstream _sum_file;
            _sum_file.open("SUM_people.log",ios::out);
            _sum_file<<"0"<<endl;
            _sum_file.close();
        }
    }
    return 1;
}
int _ASK_SUM(){
    int _now_sum;
    ///************************************************************************
    freopen("SUM_people.log","r",stdin);
    cin>>_now_sum;
    fclose(stdin);
    cout<<"The sum of people have registered here is:"<<_now_sum<<endl;
    ///************************************************************************
    ofstream record_file;
    record_file.open("pre_record.log",ios::app);
    record_file<<"DATE:";

    record_file<<_DATE;

    record_file<<"we have asked the sum of the people have registered here"<<
    endl;
    record_file.close();
    ///*************************************************************************
    return 1;
}
int _BEGIN_MUSIC(){
    system("_begin_music.bat");
    return 1;
}
int _QUERY(){

    system("QUERY.bat");
    ///************************************************************************
    freopen("the_name_we_used_now.txt","r",stdin);
    cin>>_now_name;
    fclose(stdin);
    ///************************************************************************
    ofstream record_file;
    record_file.open("pre_record.log",ios::app);
    record_file<<"DATE:";

    record_file<<_DATE;

    record_file<<pre_text<<_QUERY_text<<" "<<_now_name<<last_text<<endl;
    record_file.close();
    return 1;
}
int _ASK_AGE_TYPE_(){
    system("ASK_AGE_type.bat");
    ///****************************************************************
    freopen("SUM_people.log","r",stdin);
    int _now_sum;scanf("%d",&_now_sum);
    fclose(stdin);
    ///****************************************************************
    freopen("ASK_AGE_TIME_.txt","r",stdin);
    AGE_serc.clear();
    for(int i=1;i<=_now_sum;i++){
        string x; int lov_age_=0;
        cin>>x;
        for(int j=0;j<x.size();j++)
            if(isdigit(x[j]))lov_age_=lov_age_*10+x[j]-'0';
        cout<<lov_age_<<endl;
        AGE_serc.push_back(lov_age_);
    }
    fclose(stdin);
    ///****************************************************************
    system("ASK_AGE_del.bat");
    sort(AGE_serc.begin(),AGE_serc.end());
    return 1;
}
int _ASK_AGE_UPPER_(){
    for(int i=AGE_serc.size()-1;i>=0;i--){
        cout<<AGE_serc[i]<<endl;
    }
}
int _ASK_AGE_LOWER_(){
    for(int i=0;i<AGE_serc.size();i++){
        cout<<AGE_serc[i]<<endl;
    }
}
int _ASK_AGE(){
    int _now_age;
    string junior_operator;
    puts("Please choose which way you want.(upper/lower)");
    cin>>junior_operator;
    _ASK_AGE_TYPE_();
    ///******************************************************

    if(junior_operator == "upper")_ASK_AGE_UPPER_();

    if(junior_operator == "lower")_ASK_AGE_LOWER_();

    ///********************************************************
    ofstream record_file;
    record_file.open("pre_record.log",ios::app);
    record_file<<"DATE:";

    record_file<<_DATE;

    record_file<<pre_text<<"ask age "<<junior_operator<<".";

    record_file.close();

    return 1;
}
int LiangJiaJun(){
    std::ios::sync_with_stdio(false);
    cin>>read_operation;
    if(read_operation == "INSERT"){
       GetLocalTime(&_match_time);_INSERT();
    }
    if(read_operation == "DELETE"){
       GetLocalTime(&_match_time);_DELETE();
    }
    if(read_operation == "MODIFY"){
       GetLocalTime(&_match_time);_MODIFY();
    }
    if(read_operation == "ASK_SUM"){
       GetLocalTime(&_match_time);_ASK_SUM();
    }
    if(read_operation == "delete_all_profile"){
       _DELETE_ALL();
    }
    if(read_operation == "QUERY"){
       GetLocalTime(&_match_time);_QUERY();
    }
    if(read_operation == "ASK_AGE"){
       GetLocalTime(&_match_time);_ASK_AGE();
    }
    return 0;
}

